package com.ruoyi.system.service.news.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ruoyi.system.domain.news.NewsStandardSystem;
import com.ruoyi.system.domain.news.query.NewsStandardSystemQuery;
import com.ruoyi.system.domain.news.vo.NewsStandardSystemVo;
import com.ruoyi.system.domain.news.vo.NewsStandardSystemVo;
import com.ruoyi.system.mapper.news.NewsStandardSystemMapper;
import com.ruoyi.system.service.news.NewsStandardSystemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class NewsStandardSystemServiceImpl extends ServiceImpl<NewsStandardSystemMapper, NewsStandardSystem>
        implements NewsStandardSystemService {

    @Override
//    @DataScope(deptAlias = "t",userAlias = "t")
    public List<NewsStandardSystemVo> getNewsStandardSystemList(NewsStandardSystemQuery newsStandardSystemQuery) {
        if (newsStandardSystemQuery.getIfPage()) {
            PageHelper.startPage(newsStandardSystemQuery.getPageNum(), newsStandardSystemQuery.getPageSize());
        }
        List<NewsStandardSystemVo> newsStandardSystemVoList = baseMapper.getNewsStandardSystemList(newsStandardSystemQuery);
        if (!newsStandardSystemVoList.isEmpty() && newsStandardSystemQuery.getId() == null) {
            for (NewsStandardSystemVo newsStandardSystemVo:newsStandardSystemVoList) {
                newsStandardSystemVo.setContent(null);
            }
        }
        return newsStandardSystemVoList;
    }
}
